package leecode

func detectCapitalUse(word string) bool {
	// a:97  A:65
	wordByte := []byte(word)
	var (
		one   bool
		two   bool
		three bool
	)
	//全部字母都是大写
	for i := 0; i < len(wordByte); i++ {
		if wordByte[i] >= 'A' && wordByte[i] <= 'Z' {
			one = true
		} else {
			one = false
			break
		}
	}
	//全部字母都是小写
	for i := 0; i < len(wordByte); i++ {
		if wordByte[i] >= 'a' && wordByte[i] <= 'z' {
			two = true
		} else {
			two = false
			break
		}
	}
	//首字母大写
	if wordByte[0] >= 'A' && wordByte[0] <= 'Z' {
		for i := 1; i < len(wordByte); i++ {
			if wordByte[i] >= 'a' && wordByte[i] <= 'z' {
				three = true
			} else {
				three = false
				break
			}
		}
	}
	return one || two || three
}
